from PySide6.QtCore import Qt
from PySide6.QtWidgets import QWidget, QVBoxLayout
from qfluentwidgets import MessageBoxBase, SubtitleLabel, TextEdit, PushButton, FluentIcon

class TextEditDialog(MessageBoxBase):
    """ 自定义多行文本输入对话框 """

    def __init__(self, title: str, text: str = "", parent=None):
        super().__init__(parent)
        self.titleLabel = SubtitleLabel(title)
        self.textEdit = TextEdit()
        
        # 设置文本框属性
        self.textEdit.setPlaceholderText("请输入内容...")
        self.textEdit.setText(text)
        self.textEdit.setMinimumHeight(200)
        
        # 将组件添加到布局中
        self.viewLayout.addWidget(self.titleLabel)
        self.viewLayout.addWidget(self.textEdit)
        
        # 设置对话框的最小宽度
        self.widget.setMinimumWidth(500)
        
        # 设置确定和取消按钮的文本
        self.yesButton.setText('确定')
        self.cancelButton.setText('取消')
        
        # 设置确定按钮的图标
        self.yesButton.setIcon(FluentIcon.ACCEPT)

    def getText(self) -> str:
        """ 获取文本内容 """
        return self.textEdit.toPlainText() 